找传奇、传世资源到传世资源站!

C# 会员登录示例源码(access数据库)

8.5玩家评分(1人评分)
下载后可评
介绍 评论 失效链接反馈

from clipboard
from clipboardusing System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Data.OleDb;namespace Case05_5{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { if (textBox1.Text == "" || textBox2.Text == "") { MessageBox.Show("输入登录信息不完整,请从新输入!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information); //提示对话框 } else { string mypath = Application.StartupPath "\\mydata.mdb"; //连接数据库的路径及数据库名 string constr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" mypath ";Mode=ReadWrite|Share Deny None;Persist Security Info=False"; //生成连接数据库字符串 OleDbConnection mycon = new OleDbConnection(constr); //定义OleDbConnection对象实例并连接数据库 mycon.Open(); string mysql = "select * from person where 用户名 = '" textBox1.Text "' and 密码= '" textBox2.Text "'"; //Sql查询语句 OleDbDataAdapter myada = new OleDbDataAdapter(mysql, mycon); DataTable mydt = new DataTable(); myada.Fill(mydt); int i = mydt.Rows.Count; if (i >= 1) { Form2 myf = new Form2(); myf.Show(); //显示主界面 myf.label1.Text = "欢迎 " textBox1.Text " 登录主界面 ,其登录密码是: " textBox2.Text; } else { MessageBox.Show("用户名或密码不正确,请重新输入!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information); //提示对话框 } } } private void button2_Click(object sender, EventArgs e) { this.textBox1.Text = ""; //清空文本框 this.textBox2.Text = ""; } private void button3_Click(object sender, EventArgs e) { Application.Exit(); //退出程序 } }}

评论

发表评论必须先登陆, 您可以 登陆 或者 注册新账号 !


在线咨询: 问题反馈
客服QQ:174666394

有问题请留言,看到后及时答复